home *** CD-ROM | disk | FTP | other *** search
- /*
- ** Apple Macintosh Developer Technical Support
- **
- ** File: Colors.c
- ** Written by: Eric Soldan
- **
- ** Copyright © 1993 Apple Computer, Inc.
- ** All rights reserved.
- */
-
- /* You may incorporate this sample code into your applications without
- ** restriction, though the sample code has been provided "AS IS" and the
- ** responsibility for its operation is 100% yours. However, what you are
- ** not permitted to do is to redistribute the source as "DSC Sample Code"
- ** after having made changes. If you're going to re-distribute the source,
- ** we require that you make it clear in the source that the code was
- ** descended from Apple Sample Code, but that you've made changes. */
-
-
-
- /*****************************************************************************/
-
-
-
- #include "App.h" /* Get the application includes/typedefs, etc. */
- #include "App.defs.h" /* Get various application definitions. */
- #include "App.protos.h" /* Get the prototypes for the application. */
-
- #ifndef __PICKER__
- #include <Picker.h>
- #endif
-
- #ifndef __TREEOBJ2__
- #include "TreeObj2.h"
- #endif
-
- extern RGBColor gBorderColor, gContentColor;
-
-
-
- /*****************************************************************************/
- /*****************************************************************************/
-
-
-
- #pragma segment Color
- OSErr ChangeColor(FileRecHndl frHndl, WindowPtr window, short part)
- {
- #ifndef __MWERKS__
- #pragma unused (window)
- #endif
-
- short i;
- TreeObjHndl root, cobj;
- RGBColor rgb, rgb2;
- Boolean gotColor;
- static Point minus1Org = {-1, -1};
-
- rgb = (part == kBorderColor) ? gBorderColor : gContentColor;
- gotColor = false;
-
- root = (*frHndl)->d.doc.root;
- for (i = (*root)->numChildren; i;) {
- cobj = GetChildHndl(root, --i);
- if (DoTreeObjMethod(cobj, GETSELECTMESSAGE, 0)) {
- if ((*cobj)->type < GROUPOBJ) {
- rgb2 = (part == kBorderColor) ? mDerefCommon(cobj)->borderColor :
- mDerefCommon(cobj)->contentColor;
- if (!gotColor) {
- gotColor = true;
- rgb = rgb2;
- continue;
- }
- if (
- (rgb.red != rgb2.red) ||
- (rgb.green != rgb2.green) ||
- (rgb.blue != rgb2.blue)
- ) {
- switch (part) {
- case kBorderColor:
- rgb.red = rgb.green = rgb.blue = 0;
- break;
- case kContentColor:
- rgb.red = rgb.green = rgb.blue = 0xFFFF;
- break;
- }
- }
- }
- }
- }
-
- if (GetColor(minus1Org, "\p", &rgb, &rgb2)) {
- if (part == kBorderColor)
- gBorderColor = rgb2;
- else
- gContentColor = rgb2;
- for (i = (*root)->numChildren; i;) {
- cobj = GetChildHndl(root, --i);
- if (DoTreeObjMethod(cobj, GETSELECTMESSAGE, 0)) {
- if ((*cobj)->type < GROUPOBJ) {
- if (ModifyChild(COLORCHANGE_EDIT, root, i, false)) return(memFullErr);
- if (part == kBorderColor)
- mDerefCommon(cobj)->borderColor = rgb2;
- else
- mDerefCommon(cobj)->contentColor = rgb2;
- }
- }
- }
- DoImageDocument(frHndl);
- }
-
- return(noErr);
- }
-
-
-
-